package fr.umlv.m2.uwp2011.service.matiere.impl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.stereotype.Service;

import fr.umlv.m2.uwp2011.persistence.matiere.Cursus;
import fr.umlv.m2.uwp2011.persistence.matiere.dao.HibernateCursusDAO;
import fr.umlv.m2.uwp2011.service.matiere.DisplayCursus;
import fr.umlv.m2.uwp2011.service.matiere.ICursusService;

@Service("cursusService")
public class CursusServiceImpl implements ICursusService {

	private final HibernateCursusDAO hibernateCursusDAO = new HibernateCursusDAO();
	
	@Override
	public List<DisplayCursus> getListCursusByUser(String user_id) {
		List<Cursus> listCursus = hibernateCursusDAO.findByUserID(user_id);
		List<DisplayCursus> listDisplayCursus = new ArrayList<DisplayCursus>(listCursus.size());
		
		for(Cursus cursus : listCursus) {
			DisplayCursus dc = new DisplayCursus();
			dc.setCursus(cursus);
			listDisplayCursus.add(dc);
		}
		
		return listDisplayCursus;
	}

}
